<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
namespace app\address\admin;

use app\common\builder\ZBuilder;
use app\admin\controller\Admin;
use app\address\model\Address as AddressModel;

/**
 * 地址管理
 * @package app\admin\controller
 */
class Index extends Admin{
    
    public function index()
    {
        $map = $this->getMap();
        // 排序
        $order = $this->getOrder('createtime desc');
        // 数据列表
        $data_list = AddressModel::where($map)->order($order)->paginate();

        return ZBuilder::make('table')
            ->setSearch(['address' => '地址']) // 设置搜索框
            ->addColumns([ // 批量添加数据列
                ['id', 'ID'],
                ['openid', '用户', 'text'],
                ['province', '省份', 'text'],
                ['city', '城市', 'text'],
                ['district', '地区', 'text'],
                ['address','详细地址','text'],
                ['createtime', '更新时间', 'text'],
                ['projectid', '项目', 'text'],
                ['right_button', '操作', 'btn']
            ])
            ->addTopButtons('add,enable,disable,delete') // 批量添加顶部按钮
            ->addRightButtons(['edit', 'delete' => ['data-tips' => '删除后无法恢复。']]) // 批量添加右侧按钮
            ->setRowList($data_list) // 设置表格数据
            ->fetch(); // 渲染模板
    }
}
